
import { useLaunch } from '@tarojs/taro'
import React, { useState } from 'react';
import { TabContext } from './context'
import './app.scss'

export const useGlobalTab = () => useContext(TabContext);

const App = ({ children }) => {
  // 默认索引为 0
  const [tabIndex, setTabIndex] = useState(0);

  useLaunch(() => {
    console.log('App launched.')
  })

  // children 是将要会渲染的页面
  return (
    <TabContext.Provider value={{ tabIndex, setTabIndex }}>
      {children}
    </TabContext.Provider>
  )
}

export default App
